﻿<Application
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:music="clr-namespace:WickedSick.ClientComponents.Music;assembly=WickedSick.ClientComponents.Music"
    xmlns:local="clr-namespace:SDB"
    x:Class="SDB.App"
	StartupUri="Window1.xaml">
	<Application.Resources>
        <SolidColorBrush x:Key="CobaltBlue" Color="#FF576C8B"/>
        <SolidColorBrush x:Key="LightCobaltBlue" Color="#FFAFBCCD"/>
        <SolidColorBrush x:Key="SlightBlue" Color="#FFDCE1EA"/>

        <local:MediaValueConverter x:Key="mediaConverter" />
        <local:SongItemStyleSelector x:Key="SongItemStyleSelector"/>

        <ContextMenu x:Key="MyContext">
            <MenuItem Header="Add To Playlist"/>
        </ContextMenu>

        <VisualBrush x:Key="BackgroundVisualBrush"  TileMode="Tile" Viewbox="0, 0, 40, 40" ViewboxUnits="Absolute" Viewport="0, 0, 80, 80" ViewportUnits="Absolute">
            <VisualBrush.Visual>
                <Grid Width="40" Height="40">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20"></ColumnDefinition>
                        <ColumnDefinition Width="20"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"></RowDefinition>
                        <RowDefinition Height="20"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Border Grid.ColumnSpan="2" Grid.RowSpan="2" Background="#FFAFBCCD"/>
                    <Border Grid.Column="0" Grid.Row="0" Background="White" Opacity=".1"/>
                    <Border Grid.Column="1" Grid.Row="1" Background="White" Opacity=".1"/>
                </Grid>
            </VisualBrush.Visual>
        </VisualBrush>

        <Style x:Key="HideTabHeader" TargetType="{x:Type TabItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate></ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="HorizontalListBox" TargetType="{x:Type ListBox}">
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" Width="Auto" Height="Auto"/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type ListBoxItem}">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border Cursor="Hand" Name="TabHeaderBorder" SnapsToDevicePixels="True" Margin="12,12,0,12" Width="80" CornerRadius="5" Background="{DynamicResource SlightBlue}">
                            <Border CornerRadius="5" Margin="2" BorderBrush="{DynamicResource CobaltBlue}" BorderThickness="1">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FFDCE1EA" Offset="0"/>
                                        <GradientStop Color="#FFAFBCCD" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                                <ContentPresenter/>
                            </Border>
                            <Border.BitmapEffect>
                                <DropShadowBitmapEffect/>
                            </Border.BitmapEffect>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="ListBoxItem.IsSelected" Value="True">
                                <Setter TargetName="TabHeaderBorder" Property="Margin" Value="10, 10, 2, 14"/>
                                <Setter TargetName="TabHeaderBorder" Property="BitmapEffect" Value="{x:Null}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type local:TabHeader}">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:TabHeader}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition Height="22"/>
                            </Grid.RowDefinitions>
                            <Image Source="{TemplateBinding local:TabHeader.TabHeaderImage}" Width="32" Height="32"/>
                            <TextBlock Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontWeight="Bold" FontFamily="Segoe" FontSize="16" Foreground="#FFDCE1EA" Text="{TemplateBinding local:TabHeader.TabHeaderText}" TextWrapping="Wrap"/>
                		    <TextBlock Grid.Row="1" HorizontalAlignment="Center" Margin="0,0,1,1" VerticalAlignment="Bottom" FontWeight="Bold" FontFamily="Segoe" FontSize="16" Foreground="#FF576C8B" Text="{TemplateBinding local:TabHeader.TabHeaderText}" TextWrapping="Wrap"/>
                	    </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="PlaylistItemStyle" TargetType="{x:Type local:PlaylistListBoxItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:PlaylistListBoxItem}">
                        <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="False" />
                                    <Condition Property="IsPlaying" Value="True" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Foreground" Value="White" />
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource CobaltBlue}" />
                                <Setter Property="BorderThickness" TargetName="Bd" Value="1"/>
                                <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
                            </MultiTrigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Foreground" Value="{DynamicResource CobaltBlue}"/>
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource SlightBlue}"/>
                                <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource CobaltBlue}"/>
                                <Setter Property="BorderThickness" TargetName="Bd" Value="1"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="Selector.IsSelectionActive" Value="false"/>
                                    <Condition Property="IsPlaying" Value="true"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Foreground" Value="White"/>
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource CobaltBlue}"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ShadowedTextBlock" TargetType="{x:Type Label}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Label}">
                        <Grid>
                            <TextBlock SnapsToDevicePixels="True" Margin="4, 4, 3, 3" FontFamily="{TemplateBinding FontFamily}" FontWeight="Bold" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}"/>
                            <TextBlock SnapsToDevicePixels="True" Margin="3" FontFamily="{TemplateBinding FontFamily}" FontWeight="Bold" FontSize="{TemplateBinding FontSize}" Foreground="#FF576C8B" Text="{TemplateBinding Content}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <HierarchicalDataTemplate DataType="{x:Type music:Artist}" ItemsSource="{Binding Path=Albums.Values}">
            <Label Style="{StaticResource ShadowedTextBlock}" Content="{Binding Name}" 
                   FontFamily="Segoe" FontSize="16" Foreground="#FFDCE1EA" />
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate DataType="{x:Type music:Album}" ItemsSource="{Binding Path=Songs.Values}">
            <StackPanel>
                <Image Margin="8" HorizontalAlignment="Left" Source="D:\Personal\mp3s\AlbumArt_{0B6BE3A3-9D5D-488B-8802-69C8D696E85F}_Small.jpg">
                    <Image.BitmapEffect>
                        <DropShadowBitmapEffect />
                    </Image.BitmapEffect>
                </Image>
                <Label Margin="8, 0, 0, 0" Style="{StaticResource ShadowedTextBlock}" Content="{Binding Name}" 
                           FontFamily="Segoe" FontSize="14" Foreground="#FFDCE1EA" />
                <Label Margin="8, 0, 0, 0" Style="{StaticResource ShadowedTextBlock}" 
                       FontFamily="Segoe" FontSize="14" Foreground="#FFDCE1EA"
                       Content="{Binding Path=ReleaseDate, Converter={StaticResource mediaConverter}, ConverterParameter=ReleaseDate}" />
                <Label Margin="8, 0, 0, 0" Style="{StaticResource ShadowedTextBlock}" 
                       FontFamily="Segoe" FontSize="14" Foreground="#FFDCE1EA"
                       Content="{Binding Path=Songs.Count, Converter={StaticResource mediaConverter}, ConverterParameter=AlbumSongCount}" />
            </StackPanel>
        </HierarchicalDataTemplate>
        <DataTemplate DataType="{x:Type music:Song}">
            <Grid ContextMenu="{StaticResource MyContext}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Image Source="images\0119.ico" Width="16" Height="16" Margin="2, 2, 5, 2"/>
                <TextBlock Grid.Column="1" SnapsToDevicePixels="True" Margin="4, 4, 3, 3" FontFamily="Segoe" FontSize="14" Foreground="#FFDCE1EA">
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource mediaConverter}" ConverterParameter="TrackNumberTitle">
                            <Binding Path="TrackNumber" />
                            <Binding Path="Title" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
                <TextBlock Grid.Column="1" SnapsToDevicePixels="True" Margin="3" FontFamily="Segoe" FontSize="14" Foreground="#FF576C8B">
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource mediaConverter}" ConverterParameter="TrackNumberTitle">
                            <Binding Path="TrackNumber" />
                            <Binding Path="Title" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
            </Grid>
        </DataTemplate>

        <Style x:Key="ArtistStyle" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Border BorderBrush="#FF576C8B" BorderThickness="1, 1, 1, 0">
                            <StackPanel>
                                <Border CornerRadius="3">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFDCE1EA" Offset="0"/>
                                            <GradientStop Color="#FFAFBCCD" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                    <Grid>
                                        <ContentPresenter x:Name="PART_Header" ContentSource="Header" Margin="10, 0, 10, 0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                                    </Grid>
                                </Border>
                                <Border Background="#FF576C8B">
                                    <Grid x:Name="ItemsHost">
                                        <ItemsPresenter HorizontalAlignment="Stretch"/>
                                    </Grid>
                                </Border>
                            </StackPanel>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="false">
                                <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="AlbumStyle" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Border Margin="150, 0, 20, 0" BorderBrush="#33BFC5D4" BorderThickness="0, 1, 0, 0">
                            <Border BorderBrush="#FF8088A6" BorderThickness="0, 0, 1, 0" Background="#FFDCE1EA">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="100"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="Top"/>
                                    <ItemsPresenter x:Name="ItemsHost" Grid.Column="1"/>
                                </Grid>
                            </Border>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="SongStyle" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Border Name="Bd" HorizontalAlignment="Left" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                            <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="Bd" Property="Background" Value="#FFAFBCCD"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>
</Application>